from datetime import datetime
from typing import Optional

from pydantic import BaseModel

from app.schemas.base_model import OrmBaseModel


class BarBase(OrmBaseModel):
    id: Optional[int]
    marketType: Optional[str]
    instrumentId: Optional[int]
    frequency: Optional[str]
    low: Optional[float]
    high: Optional[float]
    open: Optional[float]
    close: Optional[float]
    volume: Optional[float]
    amount: Optional[float]
    preClose: Optional[float]
    change: Optional[float]
    pctChange: Optional[float]
    turn: Optional[float]
    tradeStatus: Optional[int]
    adjustFlag: Optional[int]
    isSt: Optional[int]
    peTtm: Optional[float]
    pbMrq: Optional[float]
    psTtm: Optional[float]
    pcfNcfTtm: Optional[float]
    factor: Optional[float]
    barDate: Optional[datetime]
    createdDate: Optional[datetime]
    updatedDate: Optional[datetime]

class Candlestick(OrmBaseModel):
    low: float
    high: float
    open: float
    close: float
    volume: float
    amount: float
    barDate: datetime


class CandlestickQuery(BaseModel):
    pickerId: Optional[int]
    instrumentId: Optional[int]
    symbol: Optional[str]
    adjust: Optional[str]
    frequency: Optional[str]
    marketType: Optional[str]
    barDate: Optional[datetime]
    isSt: Optional[int]
    tradeStatus: Optional[int]
    userId: Optional[int]
    state: Optional[str]
    start: Optional[str]
    end: Optional[str]


class BarQuery(BarBase):
    pass
